package org.esgl3d;

import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;

import android.app.Activity;
import android.os.Bundle;


import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.util.Linkify;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.AdapterContextMenuInfo;


/**
 * Main menu activity
 * 
 * @author Lee
 */
public class Startup extends ListActivity  
{
	private final int CONTEXTID_VIEWFILE = 0;
	private final int CONTEXTID_CANCEL = 1;
		
	private Class<?>[] classes = {
		ExMinimalActivity.class,
		ExTexturedBoxActivity.class,
		ExBitmapFontActivity.class,
		ExAsteroidChaseActivity.class,
	};
	
	private String[] strings = {
			"Two spinning pyramids", 
			"A textured box",
			"Simple bitmap font (displays fps)",
			"Asteroid chase (sample game)"
		};
		
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
	    super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        InputStream logFile = getResources().openRawResource(R.raw.logging);
		try { 
			LogManager.getLogManager().readConfiguration(logFile);

			LogCatHandler handler = new LogCatHandler();
			handler.setLevel(java.util.logging.Level.ALL);

			LogManager.getLogManager().getLogger("").addHandler(handler);
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
	    setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, strings));
	     

	    registerForContextMenu(getListView());   	    
    }
    
    @Override
    public void onListItemClick(ListView parent, View v, int position, long id)
    {
    	this.startActivity( new Intent(this, classes[position] ) );
    }    
}
